﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    public class LoginStatisticModel
    {
        private int _Sec;
        [DataMember]
        public int Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _empID;
        [DataMember]
        public int empID
        {
            get { return _empID; }
            set { _empID = value; }
        }
        private int _ExameID;
        [DataMember]
        public int ExameID
        {
            get { return _ExameID; }
            set { _ExameID = value; }
        }
        private DateTime? _LoginTime;
        [DataMember]
        public DateTime? LoginTime
        {
            get { return _LoginTime; }
            set { _LoginTime = value; }
        }
        private string _EmpName;
        [DataMember]
        public string EmpName
        {
            get { return _EmpName; }
            set { _EmpName = value; }
        }
        private string _CardNo;
        [DataMember]
        public string CardNo
        {
            get { return _CardNo; }
            set { _CardNo = value; }
        }
        private string _OrgName;
        [DataMember]
        public string OrgName
        {
            get { return _OrgName; }
            set { _OrgName = value; }
        }
        private string _BuMen;
        [DataMember]
        public string BuMen
        {
            get { return _BuMen; }
            set { _BuMen = value; }
        }
        private string _ZhiWei;
        [DataMember]
        public string ZhiWei
        {
            get { return _ZhiWei; }
            set { _ZhiWei = value; }
        }

        public static LoginStatisticModel FillEntity(DataRow dr)
        {
            LoginStatisticModel right = new LoginStatisticModel();
            if (dr.Table != null && dr.Table.Columns.Contains("empID")) right.empID = Convert.ToInt32(dr["empID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("ExameID")) right.ExameID = Convert.ToInt32(dr["ExameID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) right.Sec = Convert.ToInt32(dr["Sec"]);
            if (dr.Table != null && dr.Table.Columns.Contains("ID")) right.ID = Convert.ToInt32(dr["ID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("EmpName")) if (!string.IsNullOrEmpty(dr["EmpName"].ToString())) right.EmpName = dr["EmpName"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("CardNo")) if (!string.IsNullOrEmpty(dr["CardNo"].ToString())) right.CardNo = dr["CardNo"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("OrgName")) if (!string.IsNullOrEmpty(dr["OrgName"].ToString())) right.OrgName = dr["OrgName"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("BuMen")) if (!string.IsNullOrEmpty(dr["BuMen"].ToString())) right.BuMen = dr["BuMen"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("ZhiWei")) if (!string.IsNullOrEmpty(dr["ZhiWei"].ToString())) right.ZhiWei = dr["ZhiWei"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("LoginTime")) if (!string.IsNullOrEmpty(dr["LoginTime"].ToString()) && Convert.ToDateTime(dr["LoginTime"]) != Convert.ToDateTime("1900-01-01")) right.LoginTime = Convert.ToDateTime(dr["LoginTime"]);

            return right;
        }
    }
}
